<?php
       if($user_arr["usertype"]=="1"){
            $normaluserstyle = " ";
            $businessuserstyle = " display:none; ";
       }
       else{
           $normaluserstyle = " display:none; ";
           $businessuserstyle = "";
       }
       ?>
<style>
.normal{
<?php echo $normaluserstyle; ?>
}
.business{
<?php echo $businessuserstyle; ?>
}
</style>
</style>
<script language="javascript">
    function validatefrom(){
        var user_type=document.getElementById("user_type"); //$("#user_type");
        var user_email=$("#user_email");
        var user_passwd  =$("#user_passwd ");
        var confirm_user_passwd=$("#confirm_user_passwd");
        var secret_question =$("#secret_question ");
        var secret_answer =$("#secret_answer");
        var user_firstname =$("#user_firstname");
        var user_lastname =$("#user_lastname");
        var Designation =$("#Designation");
        var companyname =$("#companyname ");
        var companyaddress=$("#companyaddress");
        var user_phone=$("#user_phone");
        var user_fax =$("#user_fax");
        var typeofbusiness =$("#typeofbusiness");
        var businessregistration =$("#businessregistration ");
        var industry=$("#industry");
        var prefferedpayment =$("#prefferedpayment ");
        var Status = document.getElementById("cmbStatus");
        var profession =$("#profession");
        var nicno =$("#nicno");
        var user_address =$("#user_address");


	if(user_type.value == "")
	{
		alert("User Type cannot  be blank");
                user_type.focus();
		return false;
	}else if(user_email.val() == "")
	{
		alert("Email cannoty be blank");
                user_email.focus();
		return false;
	}else if(secret_question.val() == "") {
		alert("Secret Question cannot be blank");
		secret_question.focus();
		return false;
	}  else if(secret_answer.val() == "") {
		alert("Secret Answer cannot be blank");
		secret_answer.focus();
		return false;
	}  else if(user_firstname.val() == "") {
		alert("First Name cannot be blank");
		user_firstname.focus();
		return false;
	} else if(user_lastname.val() == "") {
		alert("last Name cannot be blank");
		user_lastname.focus();
		return false;
	} else if(user_passwd.val()!= "") {
            if(user_passwd.val() != confirm_user_passwd.val())
            {
		alert("Password confirmaton failed");
		user_passwd.focus();
		return false;
	     }
             else if(passvalidator(user_passwd.val())==false)
             {
		alert("password must be at least six characters long");
		user_passwd.focus();
		return false;
	     }
	} else if(user_type.val()==1){
            if(profession.val() == "") {
                    alert("Profession is required and cannot be blank");
                    profession.focus();
                    return false;
            }else if(nicno.val() == "") {
                    alert("NIC no is required and cannot be blank");
                    nicno.focus();
                    return false;

            }else if(user_address.val()=="") {
                    alert("User Address is required and cannot be blank");
                    user_address.focus();
                    return false;

            } else if(user_phone.val() == "") {
                            alert("Phone cannot be blank");
                            user_phone.focus();
                            return false;
                    }
        }
        else if(user_type.val()==2){
                     if(Designation.val() == "") {
                        alert("Designation cannot be blank");
                        Designation.focus();
                        return false;
                    } else if(companyname .val() == "") {
                            alert("company name cannot be blank");
                            companyname .focus();
                            return false;
                    } else if(companyaddress.val() == "") {
                            alert("company address cannot be blank");
                            companyaddress.focus();
                            return false;
                    }else if(user_fax.val() == ""  ) {
                            alert("Fax cannot be blank");
                            user_fax.focus();
                            return false;
                    }else if(typeofbusiness.val() == "" ) {
                            alert("Business type cannot be blank");
                            typeofbusiness.focus();
                            return false;
                    }else if(industry.val() == "") {
                            alert("industry cannot be blank");
                            industry.focus();
                            return false;
                    }else if(prefferedpayment .val() == "" && user_type.value==2) {
                            alert("preffered payment  cannot be blank");
                            prefferedpayment .focus();
                            return false;
                    }
            }
}
function passvalidator(password ){

    var passed = validatePassword(password, {
	length:   [6, Infinity]
});
return passed;
}

</script>
<h2>Edit Profile</h2>
<?php //print_r($user_arr); ?>
<div class="userimpforms">
	<form name="registerform" action="<?php echo SITEURL; ?>index.php?doeditprofile" method="post" onsubmit="return validatefrom();" >
		<div class="field select clearfix">
			<div class="klbl">User Type : </div>
			<div class="elmnt">
				<select name="user_type" id="user_type">
				<option value="">Select user type</option>
				<option <?php echo ($user_arr["usertype"]=="1")?"selected":""; ?>  value="1">Individual User</option>
				<option <?php echo ($user_arr["usertype"]=="2")?"selected":""; ?>  value="2">Business User</option>
				</select>
			</div>
		</div>
		<div class="field input clearfix">
			<div class="klbl">First Name : </div>
			<div class="elmnt"><input type="text" name="user_firstname" id="user_firstname" value="<?php echo $user_arr["user_firstname"];?>" class="inp-form" size="40" /></div>
		</div>
		<div class="field input clearfix">
			<div class="klbl">Last Name : </div>
			<div class="elmnt"><input type="text" name="user_lastname" id="user_lastname" value="<?php echo $user_arr["user_lastname"];?>" class="inp-form" size="40" /></div>
		</div>
		<div class="field input clearfix normal">
			<div class="klbl">Profession : </div>
			<div class="elmnt"><input type="text" name="profession" id="profession" value="<?php echo $user_arr["profession"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix normal ">
			<div class="klbl">Contact Address : </div>
			<div class="elmnt"><input type="text" name="user_address" id="user_address" value="<?php echo $user_arr["user_address"];?>" class="inp-form" size="60" /></div>
		</div>
		<div class="field input clearfix ">
			<div class="klbl">Tel No : </div>
			<div class="elmnt"><input type="text" name="user_phone" id="user_phone" value="<?php echo $user_arr["user_phone"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix normal">
			<div class="klbl">NIC No : </div>
			<div class="elmnt"><input type="text" name="nicno" id="nicno" value="<?php echo $user_arr["nicno"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix">
			<div class="klbl">E-Mail : </div>
			<div class="elmnt"><?php echo $user_arr["user_email"];?></div>
		</div>
		<div class="field input clearfix">
			<div class="klbl">Password : (minimum 6 characters)</div>
			<div class="elmnt"><input onkeyup="passwordStrength(this.value)" type="password" name="user_passwd" id="user_passwd" value="" class="inp-form" />
                        &nbsp;<div id="passwordDescription"></div><div id="passwordStrength" class="strength0"></div>
                        </div>

		</div>
		<div class="field input clearfix">
			<div class="klbl">Confirm Password : </div>
			<div class="elmnt"><input type="password" name="confirm_user_passwd" id="confirm_user_passwd" value="" class="inp-form" /></div>
		</div>
		<div class="field select clearfix">
			<div class="klbl">Security Question : </div>
			<div class="elmnt">
                         <select id="secret_question" name="secret_question" >
								<option  <?php echo ($user_arr["secret_question"]=="")?"selected":""; ?> value="">Select your secret question...</option>
								<option  <?php echo ($user_arr["secret_question"]=="What street did you grow up on?")?"selected":""; ?> value="What street did you grow up on?">What street did you grow up on?</option>
								<option  <?php echo ($user_arr["secret_question"]=="What is your mother's maiden name?")?"selected":""; ?> value="What is your mother's maiden name?">What is your mother's maiden name?</option>
								<option  <?php echo ($user_arr["secret_question"]=="What is the name of your first school?")?"selected":""; ?> value="What is the name of your first school?">What is the name of your first school?</option>
								<option  <?php echo ($user_arr["secret_question"]=="What is your pet's name?")?"selected":""; ?> value="What is your pet's name?">What is your pet's name?</option>
								<option  <?php echo ($user_arr["secret_question"]=="What is your father's middle name?")?"selected":""; ?> value="What is your father's middle name?">What is your father's middle name?</option>
								<option  <?php echo ($user_arr["secret_question"]=="What is your school's mascot?")?"selected":""; ?> value="What is your school's mascot?">What is your school's mascot?</option>
                         </select>
                           </div>
		</div>
		<div class="field input clearfix">
			<div class="klbl">Security Answer : </div>
			<div class="elmnt"><input type="text" name="secret_answer" id="secret_answer" value="<?php echo $user_arr["secret_answer"];?>" class="inp-form" size="60" /></div>
		</div>		
		<div class="field input clearfix business">
			<div class="klbl">Designation : </div>
			<div class="elmnt"><input type="text" name="Designation" id="Designation" value="<?php echo $user_arr["Designation"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix business">
			<div class="klbl">Company Name : </div>
			<div class="elmnt"><input type="text" name="companyname" id="companyname" value="<?php echo $user_arr["companyname"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix business">
			<div class="klbl">Company Address : </div>
			<div class="elmnt"><input type="text" name="companyaddress" id="companyaddress" value="<?php echo $user_arr["companyaddress"];?>" class="inp-form" size="60"/></div>
		</div>		
		<div class="field input clearfix business">
			<div class="klbl">Fax : </div>
			<div class="elmnt"><input type="text" name="user_fax" id="user_fax" value="<?php echo $user_arr["user_fax"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix business">
			<div class="klbl">Type Of Business : </div>
			<div class="elmnt"><input type="text" name="typeofbusiness" id="typeofbusiness" value="<?php echo $user_arr["typeofbusiness"];?>" class="inp-form" /></div>
		</div>
		<div class="field input clearfix business">
			<div class="klbl">Industry : </div>
			<div class="elmnt"><input type="text" name="industry" id="industry" value="<?php echo $user_arr["industry"];?>" class="inp-form" /></div>
		</div>
		<div class="field select clearfix business">
			<div class="klbl">Preffered Payment : </div>
			<div class="elmnt">
				<select name="prefferedpayment" id="prefferedpayment">
				<option <?php echo ($user_arr["prefferedpayment"]=="Cash")?"selected":""; ?>>Cash</option>
				<option <?php echo ($user_arr["prefferedpayment"]=="Cheque on Delivery / Credit")?"selected":""; ?>>Cheque on Delivery / Credit</option>
				</select>
			</div>
		</div>		
		<div class="field submit clearfix">
			<div class="klbl"></div>
			<div class="elmnt"><input type="hidden" name="user_id"  value="<?php echo $user_arr["user_id"];?>" /><input type="submit" value="Register" /></div>
		</div>
	</form>
</div>
<script language="javascript">
$(document).ready(function () {
       $('#user_type').change(function() {
        if ($(this).val() == "2") {
            $(".business").show();
             $(".normal").hide();
        }
        else{
            $(".business").hide();
            $(".normal").show();
        }
       });
});
</script>
